package com.ott.tool;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

public class IndexForm{
	public static JTextField field = null;
//	public static JTextField field2 = null;
	public static JTextArea textArea = null;
	public static String fileAddress = "192.168.1.242";
	//public static String filePath = "C:/Users/admin/Desktop/文档/测试用例/";
	public static String filePath = "/opt/tms/files/";
	public static JTextArea textArea2 = null;
//	public static String tomcatpath = "D:/java/apache-tomcat-7.0.78/";
	public static String tomcatpath = "/opt/tomcat/apache-tomcat-7-8081/";
	public static String url = "http://www.bestmovie.com.cn:8082/mts/versionUpdate/feedback.json";
	public static String FilePath = "/opt/tms/";
	public static String shellPathString = "/opt/initver/";

	public static void main(String[] args) {
		new IndexForm();
	}

	public IndexForm() {
		JFrame frame = new JFrame("初始化版本");
		frame.setSize(520, 500);
		frame.setDefaultCloseOperation(3);

		frame.setLayout(null);

		JPanel panel = new JPanel();
		panel.setLayout(null);
		panel.setBounds(0, 0, 500, 160);
		panel.setBorder(BorderFactory.createTitledBorder(""));
		
		
		JLabel label = new JLabel("    IP地址:    ");
		label.setFont(FormStyle.label_style);
		label.setBounds(10, 10, 95, 30);
		panel.add(label);

		field = new JTextField();
		field.setText(fileAddress);
		field.setName("text_ip");
		field.setFont(FormStyle.textField_style);
		field.setBounds(105, 10, 395, 30);
		panel.add(field);
		
//		JLabel label2 = new JLabel("影吧编号:");
//		label2.setFont(FormStyle.label_style);
//		label2.setBounds(10, 40, 95, 30);
//		panel.add(label2);
//
//		field2 = new JTextField();
//		field2.setText("TUOJIN");
//		field2.setFont(FormStyle.textField_style);
//		field2.setBounds(105, 35, 395, 30);
//		panel.add(field2);
		
		JButton open=new JButton("选择文件夹");
		open.setBounds(0, 45, 100, 30);
		open.addActionListener(new ChooseFiles());
		panel.add(open);

		textArea2 = new JTextArea();
		textArea2.setText(filePath);
		textArea2.setFont(FormStyle.textArea_style);
		textArea2.setForeground(Color.blue);
		textArea2.setEditable(true);
		textArea2.setLineWrap(false);
		textArea2.setBounds(105, 45, 390, 30);
		panel.add(textArea2);
		
		JButton button = new JButton("一键初始化");
		button.setFont(FormStyle.button_style);
		button.addActionListener(new ButtonAction());
		button.setBounds(0, 80, 150, 30);
		panel.add(button);
		
		JButton button2 = new JButton("启动Tomcat");
		button2.setFont(FormStyle.button_style);
		button2.addActionListener(new startTomcat());
		button2.setBounds(160, 80, 150, 30);
		panel.add(button2);
		
		JButton button3 = new JButton("停止Tomcat");
		button3.setFont(FormStyle.button_style);
		button3.addActionListener(new StopTomcat());
		button3.setBounds(320, 80, 150, 30);
		panel.add(button3);
		
		JButton button4 = new JButton("初始化程序环境");
		button4.setFont(FormStyle.button_style);
		button4.addActionListener(new InitEnvironment());
		button4.setBounds(0, 120, 150, 30);
		panel.add(button4);
		
		JButton button5 = new JButton("上报云端");
		button5.setFont(FormStyle.button_style);
		button5.addActionListener(new RepMts());
		button5.setBounds(160, 120, 150, 30);
		panel.add(button5);
		
		JButton button6 = new JButton("初始化数据库");
		button6.setFont(FormStyle.button_style);
		button6.addActionListener(new InitMySql());
		button6.setBounds(320, 120, 150, 30);
		panel.add(button6);
		
		JPanel panel1 = new JPanel();
		TitledBorder td = BorderFactory.createTitledBorder("响应消息");
		td.setTitleJustification(3);
		panel1.setBorder(td);
		panel1.setLayout(new GridLayout(1, 1, 0, 0));
		panel1.setBounds(0, 180, 500, 300);

		textArea = new JTextArea();
		textArea.setFont(FormStyle.textArea_style);
		textArea.setForeground(Color.blue);
		textArea.setEditable(true);
		textArea.setLineWrap(true);
		
		JScrollPane scrollPane = new JScrollPane(textArea);
		panel1.add(scrollPane);
		
		frame.add(panel);
		frame.add(panel1);

		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
	}

	
}
